package com.easycarebn.main.fragment;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.easycarebn.main.utils.IResult;
import com.easycarebn.main.utils.Utils;
import com.timbacsi.main.R;

public class FragmentBook extends Fragment {

    private View mView;
    private static FragmentBook fragment = null;
    private LinearLayout linebigstep;
    private TextView lblStep1;
    private TextView lblStep2;
    public static CallBack callBack;

    public static FragmentBook newInstance(Bundle data) {

        if (fragment == null)
            fragment = new FragmentBook();
        fragment.setArguments(data);

        return fragment;
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_datkham, null);

        return mView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Utils.setTitlePage(mView, getArguments().getString(Utils.TITLE));
        callBack = new CallBack();
        linebigstep = (LinearLayout) mView.findViewById(R.id.linebigstep);
        lblStep1 = (TextView) mView.findViewById(R.id.lblStep1);
        lblStep2 = (TextView) mView.findViewById(R.id.lblStep2);

        getActivity().getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragment_content_step, FragmentBookStep1.newInstance(fragment.getArguments()), "TAG")
                .addToBackStack(null).commit();

    }

    public class CallBack implements IResult {
        @Override
        public void onDisplay(int arg1, String arg2) {
            if (arg1 == Utils.BOOK_STEP2) {
                linebigstep.setBackground(getResources().getDrawable(R.drawable.bgr_step2));
                lblStep1.setTextColor(Color.parseColor("#00a3e0"));
                lblStep2.setTextColor(Color.parseColor("#ffffff"));
            }
        }
    }
    
    
}
